package com.huawei.weather.controller;

import com.huawei.weather.domain.WeatherResponse;
import com.huawei.weather.service.WeatherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController  //方法返回的数据格式都是json字符串
public class WeatherController {

    @Autowired
    WeatherService weatherService;


    @RequestMapping("/findWeatherByApi/{cityId}")
    public WeatherResponse findWeatherByApi(@PathVariable("cityId") String cityId){
        return weatherService.queryWeatherByApi(cityId);
    }

    @RequestMapping("/findWeatherByUser/{cityId}")
    public WeatherResponse findWeatherByUser(@PathVariable("cityId") String cityId){
        return weatherService.findWeatherByCityId(cityId);
    }

}
